package com.unitd.app.sso.controller;

import com.unitd.frame.sso.common.helper.SSOHelper;
import com.unitd.frame.sso.common.token.SSOToken;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController extends BaseController {

	@RequestMapping("/index")
	public String index(Model model) {
		SSOToken st = SSOHelper.getToken(request);
		if (st == null) {
			try {
				response.sendRedirect("/login.html");
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		} else {
			model.addAttribute("userId", st.getUid());
		}
		return "index";
	}
}